<template>
	<!-- 预定页面 -->
	<view class="content">
		<view class="top">
			<image src="../../static/images/banner_02.png" mode=""></image>
		</view>
		<view class="mid">
			<view class="mid-content">
				<view class="phone">
					<text>张三</text>
					<text>13812314563</text>
				</view>
				<view class="addr">
					<text>北京市朝阳区望京悠乐汇A座8011</text>
				</view>
			</view>

		</view>
		<view class="bottom">
			<view class="title">
				服务时间
			</view>

			<view class="time">
				<view class="left">
					<image src="../../static/images/date.png" mode=""></image>
					<!-- 时间选择组件 -->
					<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
						<view class="uni-input">{{date}}</view>
					</picker>
				</view>
				<view class="right">
					<image src="../../static/images/edit.png" mode=""></image>
					<picker mode="time" :value="time" start="09:01" end="21:01" @change="bindTimeChange">
						<view class="uni-input">{{time}}</view>
					</picker>
				</view>
			</view>
			
			<!-- 留言信息 -->
			<view class="msg">
				<view class="msg-txt">
					留言信息
				</view>
				<input type="text" value=""placeholder="输入信息" class="txt1" />
			</view>
			<view class="btn" @click="buy">
				确认预定
				
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			const currentDate = this.getDate({
				format: true
			})
			return {
				index: 0,
				date: currentDate,
				time: '12:01'
			}
		},
		methods: {
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},
			bindDateChange: function(e) {
				this.date = e.target.value
			},
			bindTimeChange: function(e) {
				this.time = e.target.value
			},
			buy(){
				// 使用showToast
				uni.showToast({
					"title":"预约成功",
					 duration: 2000,
					 "icon":"success",
					 "position":"center",
					 "mask":true,
					
				})
			}

		},
		computed: {
			startDate() {
				return this.getDate('start');
			},
			endDate() {
				return this.getDate('end');
			}
		},
	}
</script>

<style scoped>
	.content {
		width: 100%;
		height: 100%;
	}

	.top {
		width: 100%;
		height: 400rpx;
	}

	.top image {
		width: 100%;
		height: 100%;

	}

	/* 中间一小块设置成150px */
	.mid {
		width: 100%;
		height: 162rpx;
		background-color: #EFEFF4;
		display: flex;
		justify-content: center;
		align-items: center;

	}

	/* 中间填上数据 */
	.mid-content {
		background-color: #FFFFFF;
		border-radius: 10rpx;
		width: 80%;
		height: 60%;
		padding: 0px 20rpx;
	}

	/* 底部的样式 */
	.bottom {
		width: 100%;
		height: 638rpx;
		/* background-color: #4CD964; */
		padding: 0px 40rpx;
		box-sizing: border-box;
	}

	/* 时间选择器 */
	.time {
		width: 100%;
		height: 128rpx;
		margin-top: 20rpx;
		/* background-color: #007AFF; */
		overflow: hidden;
		display:flex ;
		justify-content: space-around;
		align-items: center;
	}

	.time .left {
		/* float: left; */
		display: flex;
		justify-content: space-around;
		align-items: center;
		width: 300rpx;
		
	}

	.time .right {
		/* float: left; */
		display: flex;
		justify-content: space-around;
		align-items: center;
		width: 200rpx;
	}

	.uni-input {
		font-size: 28rpx;
		border: 1px solid #CCCCCC;
	
		/* display: inline-block; */
		/* float: left; */
	}

	.time image {
		width: 30rpx;
		height: 30rpx;
		
	}
	
	.msg{
		width: 100%;
		height:128rpx;
		/* background-color: #55ff00; */
	}
	.txt1{
		width: 50%;
		border: 1rpx solid #999999;
		
	}
	.title {
		padding-top: 40rpx;
		font-weight: 600;
	}
	.msg-txt{
		margin: 20rpx 0px;
		font-weight: 600;
	}
	.btn{
		width: 100%;
		height: 96rpx;
		line-height: 96rpx;
		text-align: center;
		border: 1rpx solid #CCCCCC;
		margin-top: 60rpx;
		background-color: #ff0000;
		color: #FFFFFF;
	}
</style>
